{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f564afd4-637c-4de2-bd1e-62f6a4f0b088",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "IPython console for SymPy 1.9 (Python 3.8.10-64-bit) (ground types: python)\n",
      "\n",
      "These commands were executed:\n",
      ">>> from __future__ import division\n",
      ">>> from sympy import *\n",
      ">>> x, y, z, t = symbols('x y z t')\n",
      ">>> k, m, n = symbols('k m n', integer=True)\n",
      ">>> f, g, h = symbols('f g h', cls=Function)\n",
      ">>> init_printing()\n",
      "\n",
      "Documentation can be found at https://docs.sympy.org/1.9/\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sympy import *\n",
    "# 参考: https://zhuanlan.zhihu.com/p/400435547\n",
    "# https://zhuanlan.zhihu.com/p/400441230\n",
    "init_session()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "76da5aea-c49b-4fb5-879f-37a71bc7c2ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = symbols('x')\n",
    "y,z,k = symbols('z k y')\n",
    "# 严格的表示式判等\n",
    "(x+1)**2 == x**2 + x*2 + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7651bd04-f01a-479b-bd01-41faf523fb13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANMAAAASCAYAAADBs+vIAAAC2klEQVR4nO3aTWheRRTG8V9Cu6n9EiUtRWhrNAp1YyltoIUShFCEbtwLbgSJIAjZmC4ShdBKUfqpUEo33blzJ9LQTSuuFFyoSQhVCjUVNAvxo4Li4tzA5fomvk7e3Ax0HgjDe3Oeuf9ZDOfcM9M3NTWlqKho7erv8OwJXMM9PMB3OIdH/+fc72IGd/E7fsaXmMRjPYhvy5MrV1lLZlx9jcw0iM8wgI/xLQ5jBLM4ip9WeGlTf+ILfI0f8QiGcUhs1OEKMDW+LU+uXGUtmXFtahg/EBvpDVysPX8fb2Iar+lO2/FHh+fTmMBbGFtDfFueXLlSPLlypXiy46qXeYMYFWXd5YZxEr/iZbEzu1EnAPioGp9eY3xbnly5Ujy5cqV4suOqb6aRavwUfzeMv+A2toi0thadrMav1im+LU+uXCmeXLlSPBvGVS/znqnGuRXM8yJzDYkPsm41jq3YIerMYxXAmR7Ft+XJlausJROuegPiCl6t/q52mGy5RpzA6VVe2tQidtV+f4JXcL9H8W15cuVK8eTKleLJhqtTa7zX2o2+anwJT4rW4sEexbflyZWrrCUTrnpmOitS2Tje6zDZJbwuOhcfrvLS/9JeUUrO47l1iG/LkytXiidXrhTPhnHVM9NsNQ6tYF7uWqz0TdWtvhc9+wN4fB3i2/LkypXiyZUrxbNhXPXNdLMaR/27/NsmDmx/w+ddvmw17anGv9Ypvi1Prlwpnly5UjwbwlXfNAuiLb5PlHN1vS3Ol66L86ZlDeJZbG7ED4muR1P9opExIG5aLCXGt+XJlausJUOu5g2IseqfF/ACvsERcQY1h1ON+BlRO+4Xh73LelF0/G7hjriCtAvHxYfbougapsa35cmVq6wlQ67mZloQPfR3cKKa7AecF9lpSXe6gadEL/557BQZbU5ktwviwmBqfFueXLnKWjLkal50LSoqSlQb50xFRQ+FymYqKuqR/gFpfbZqccS1FQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 0.333333333333333$"
      ],
      "text/plain": [
       "0.3333333333333333"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1/3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "07c7e8e6-475b-4ec3-8501-26d485b5c2bb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAAUCAYAAAADU1RxAAAB0klEQVR4nM3Vz6tNURQH8M99JEWPIk/K5IbIwI8MKFGKJOK+zJkwkMmrOyHlTISZ+AeEkQFJIr9eIWZEMkBJz8BvEZF6GKx96nbeuRz33uJbu3XOOmvv/d37u9Y6tSzL/Gv0Fd634hhu4hN+4lSFdQYwmubmOIxrGMFXvMc97Me01snjC4vtwyJ8xgvMr0AANosDnWnxDeEuruA1JmE5MuxMzyNlJIbS5k+xGsMVSTTwDjdafP34VhJ7AHuxB7sYK8cwnggZqqIfa3BeSJKjjACcTnZu7iiS6AQbMQFnK8ZvSvZB7ijK0Qka+ILLbb43MRlTsAwrE4FDvSIxEetxUfvrb4rqyXEJ2/Emd3Qrx1pxyt9JMRO1ZAdRF6W6tFckBvEdFyrEvhJk14k+caIXJMaJJLuOj38x7zkeYSGmd0tilThR1apoxaxkR7sl0cAPnCv5Nk9UQxF9olnNwG18YGx1bEmDSCRYgePp+a3I9lqKuyO0LmIDDuIWnoluOiC6cB0vsSMPLpJYjG0FXz0NQs+mqPfZOFJCAK5ijugJSzBV9JLHOImj4odWSiJL409oJNsuHx5id4V10HlONHBfXHXX6LRjLujF5jl68QPrGv8FiV9g+VkDe+HKYQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{3}$"
      ],
      "text/plain": [
       "1/3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 保留分数形式\n",
    "from sympy import Rational\n",
    "Rational(1, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bb469728-e1c7-4843-ad13-9865e5115ab9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAASCAYAAAAZk42HAAABg0lEQVR4nO3WMUhVURzH8c/LRml2lAitJR0VbIoQWowKAkEcdHESQ8HC6IEIhg5CW1NQU7zRIXNoCJxcBBcRQVFS0CUREQdrODe4XO573iuvq0hfOHD538M5vx/n//+fUyqXy64DNy5bwDk8x3v8wCF+43PaxJsFiroIE2jDEXZwt9rEq34iI2jBLQzVmpg08k04vmeJeAkfo3/TdZGYje9Yj/atSdLIGM4wiYZYfBb9+IDx+misL0kjK/iEe+iLYq/xEl+cc7yXSVqxv8ELvEUjprAgGDsrTlo+0op9G3NoFlrfEp7iNMN6m0I+Zx2prfQiVGu/+7HvARxnXG8DJzn2/5ljbk3SjPQKxb2HJgzLXhsP66QrN8nUeiy02VXcxxoG0VqsrPzEjXShItyg3UJ6TQin9q54afn4m1rtmMcvPMJuFK9gGT14ILx5iuRJNAhpDp1C1sABRglG7uCr0EW6hYKN8wqLmEHHv9FblXbhIo5zOxqwJTJS+v+Mv2JcGyN/ANiOTbq2c5O6AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x - 1$"
      ],
      "text/plain": [
       "x - 1"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 化简\n",
    "expr=(x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)\n",
    "simplify(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7af9ce1c-a271-4d9d-8015-c20ed7d03ad8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAnoAAAAWCAYAAABXAzEEAAAK0klEQVR4nO2dfbAWVR3HPxeuSUnZe8w0WYo10fRys6I00auJjdLLvVKjMZCPg1oEEVloOqLXGkdMoIdefOsFKFMr0jsaTGpKCWMjqZAylkp4VTJCQCwDVIT++O7Osyz7PHfPeXb3Ofvc85l5Zp+7e3afc777+/3O2bPnnNvR19eHx+PxeDwej6f9GFbw700HHgT+E3z+DEwoOA8ucz7wF6TNM8CtwHtbmqPy4rXMDq+lZyjj6636+NhQAopu6G0EzgOOAD4M3AX0A+8vOB+u0g1cCRwFHA/sBv4AvL6FeSor3Xgts6Ibr6Vn6OLrrfp042OD83Q48Op2G3oquKbVGXGQkcBzQA96UvLY47XMDq+lZ6jj661k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tW2jKY4uo9y5O0PtAO2nSRTz3kqjZdpCxvR19fX2G58ng8Ho/H4/EUR3wdPY/H4/F4PB5Pm+Abeh6Px+PxeDxtim/oeTwej8fj8bQp/wfFEDZ8Ap7vmwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 8 x^{3} + 48 x^{2} z + 12 x^{2} + 96 x z^{2} + 48 x z + 6 x + 64 z^{3} + 48 z^{2} + 12 z + 1$"
      ],
      "text/plain": [
       "   3       2         2         2                      3       2           \n",
       "8⋅x  + 48⋅x ⋅z + 12⋅x  + 96⋅x⋅z  + 48⋅x⋅z + 6⋅x + 64⋅z  + 48⋅z  + 12⋅z + 1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 多项式展开\n",
    "expr=(1+2*x+4*y)**3\n",
    "expand(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5df1863d-d603-4270-89c0-05cec184679b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARoAAAAYCAYAAAAlDDIFAAAHdElEQVR4nO3cf4xcVRXA8c8WRSoqlSKpgeiaGBFCbINBqYK0UmwwCBWU+CPYWkSkQaxa1Jo2rhYQf4BFVIiiFH9UNCXYqGgVgdpaUUpcsdaKPygitLGNLvVHq1TrH+dN5vH2zduZ2Z3ZtzPzTSb35d777rvnnrP33nPue9s3MDCgR48ePVrJpPHuQI8eHcBS3Is92IVv4/hx7VHJ6E00PXqMnln4HF6GV2I/7sDh49inUtGuiaYfB7CqRe3fjL/g0FG08WLRx7eNSY/aS7fLP97MxU3Ygl/hfDwLL69Rv+v0lZ5opopO34bfYy8ew0ZcoLy7nxOFYq/CP0fRzn34FlbgaaPvVtvoFPknqv3l8XTR37/llHWKvuB1uA4bhNt4AF/Nq5hW3uvxBbwUP8NK3Cp8zRvxTfQ12aFHcKzwZceaK4SQ149BWx/FNFw6Bm21i06Rv5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right)} \\cos{\\left(x \\right)} + 2 \\cos^{2}{\\left(x \\right)} - 1$"
      ],
      "text/plain": [
       "                       2       \n",
       "2⋅sin(x)⋅cos(x) + 2⋅cos (x) - 1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 三角展开\n",
    "expr=sin(2*x)+cos(2*x)\n",
    "expand_trig(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5216dfc1-f787-4abb-99a5-d01a259b2c9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAYCAYAAADH9X5VAAAD+ElEQVR4nO3aW2gcdRTH8U9qHiz1hlUoCCVIsQgiQRG8VCnaGvDFYn2xoNYLiOIFRcGIYlCqFcWmigq+NKIPKi0o9sErEa/FVoxYsOItXiuJKApqEW19OFOyTmZ3ZzYzm2XZL/yZ5T//Of9zfntm/peZvpGRET16FGHBfDvQ5QxjJ37HNF7CSfPqUQn0kqZaVuJxnIlz8Q9ex9Hz6NOcqZc0T2EKi9roS9WcigO4OkfbsuIfwhbsxie4FMfirDnarZqGWmUlzWkiuI34ozq/SuFiPIq3xRBwAM/UafshXsC9OKyBzSrjP1xo/mvJdvNQmlZZSbMhMfpECY5WzZ24HoP4IUf7+7EENzZoU2X8mzGB9yuw3YzStEonzQlYhefx15xcbA83C5+PwLU52n+APbhG9g1TZfwPYwXW4t8Wrl8vng4rW+y/NK3Swl2JPjyXYeRV4fTaVH0fxpJzG3M4Uybj+DzpOy/PYilWZ5xrFD+ta7AJl4jJ8FcFfC2T0rRKJ80qcRfsyDBwG/aLce6QmvqHcDmexO0FHJov3k2OWUnTKH5a02CzmYTZ05rL80amVrVJs0iMd5/KngB+jKdxopgowh24RTzO8zzyOoGdyfGcVH2z+CmuwWO4AuvE5HdJUhpNxDuJTK1qk+Y4cffsbWDkLuzD3WJStQGvCAH3l+VpxfwmYliaqs8TP8U0uE6smN5I7B4st7buflvJ1Ko2aRYnx0bLwe8wigGxfHsPF+HvHA5MivE0b6m3HCyDX3BMqi5P/BTToK9OGWnSx6TZemxJzo1nnBtrYm8uzNKqv+b3wdXCoU2MTNf8vgp/5uz8S5G1efmxQNuiLDR7dZQ3flrXIC+jOCpVN4gLxcbjZOrcRMn91zJLq9qkmUqOi9VnnZj0/STG5pvkn8ucl7Nd1SwQf8jXqfo88TM3DfIymlG3XiTNGN4sub96ZGpVOzztFXfQ8joGLhAO78bJ+ExsM9dr36ksF0PERKq+Wfx0jwZ5ydSqNmkO4C0xfi1LXbwCW/G9eJ8yLXYY+/FAJe5Wx+nJcTxV3yh+ukuDvGRq1Z9qtE1sXA3hi6RuENvFTHq1mdXFVuwSj8yzxTuNdrMmKcRQAWeYmRj+bPZK5XyxF/Nihr2s+OlsDfKyRklaZSXNFC4TewzL8LK4C4fEZLaWYbyGB81kZTsZFJtqtRyfFPjG/4U4Ugi3XayC0qTjp/M1yMugkrTqy/hybxj34RR8VIKzncQNeEQ8Fd6p06ab4y9CXa2yXtptwre4p3q/2spCkRDb1E8Yujf+IjTUKitp9ondzV266yOsAfFuqNlubLfGX4QBDbTKGp569GhI7xvhHoXpJU2PwvwHtD0rXK6AznwAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(x - 1\\right) \\left(x^{2} + 1\\right)$"
      ],
      "text/plain": [
       "        ⎛ 2    ⎞\n",
       "(x - 1)⋅⎝x  + 1⎠"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 因式分解\n",
    "expr=x**3-x**2+x-1\n",
    "factor(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "526f4e64-7b41-4060-baf8-7882ab3147c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJAAAAAWCAYAAAAvrxV9AAADG0lEQVR4nO3aT6gVZRjH8c/NwBYq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      "text/latex": [
       "$\\displaystyle x^{3} - x^{2} + x - 1$"
      ],
      "text/plain": [
       " 3    2        \n",
       "x  - x  + x - 1"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 合并同类项\n",
    "x*y + x - 3 + 2*x**2 - z*x**2 + x**3\n",
    "collected_expr=collect(expr, x)\n",
    "collected_expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9e48fc1b-6331-41d9-a9ff-89a91ee2406f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE4AAAAWCAYAAABud6qHAAADsElEQVR4nO3YW4iVVRQH8N80hgVWjlFB0sWXIMkou0APY5NSGQPdewnKwC4PWQkhQZEcgigi7fZQRFCRD1EE1dB0oxq7YAkygnYnGmMsSS27OjZ2eVj7MMfvnPN95zJHJuoPm3UOe31rr+//rb3W2rurVCr5H83jgIL5K/EhfsKfOKXTDk0BlDCObXgRJ9RSmpZjYC7W4Dc8j63JWKewCMtwFnqwE5vwEAZbsHc4LkE/5mE2/kg2n0zjrxrPDeEgESQX4WicmVXKI+4cdOEOPNyC483gPqzAKF7GDhyB09CnNeKuwKP4Du/gGxyFS/EELkg6f2eeG0oDNuB0zMCvlUp5xM1K8tMWnG4G1wnSnsb1IioqcWCLdr/AhXjFvpF1O9bjMkHiCzk2PsN8sQP2IS4vx3UnOd6cv01hOu4W0VCLtHbWfxsDqrfjNjyWfvcV2Civ3Z2dyIu4/YFzxZZ8ULxgP07CmIiKdR1at0zI3lYN5BE3M8ndrRpvAGckOYZhQVol3sXl2D6Ja07D1en3awW6Y0kelp2ot1W70CsS55ZWvGsQRya5Iq3Vi0NwMt7AAlHRJxP3ig80iNcLdEeS7MtOZIlbjFVim8zH4/JbkBHxwo2ONXXW3ysS+fsiCW8SrcQozhYtymTgZtwqkv5VDeg/IwLnfjwn8vHxVG/Vxbgl/d6MRwoMf2UinBvBt5n/u5IcNvF1y/hdRMRS0Ue1m++WiZ7wE9Ez/tDAM1txDx4QrQu8iZEsccuxUvRwzybHjxOnhlpY1ITjtfB5krvqzP+Y5MFtrrNcvPxm4fP3DT7XLyrwB7hBtDjj1M5xP+Ml0d/MxonteFyAt8QWnlvHl3Kx+LqNNW4TpG0UAdEoabAwyRI+VtEa5fVx5aIwK0enXWwRvdaxJlJEGefhfBGN2er3lCD8mgL7d4pisEFE2o4m/etJciQ7kdeOlNktughoFzfiVKwWW2MYc3CxSBHXikuGSlQWlXpYgruSjfdEYchiRHyEeqi7Th5x2TNcpzAqzqQrRWVdINLFgEjM62s8Mw+/iONUPcxJslvkuFpYK5+4Mqq4yCNuT5I9OTqThe24KY0izBR93ioTxaMWSmm0g/K7V3UOedvwyySX4pgC3f2JXpFGVndwjemiBeoT0V91cskjY1CU735xCJ8qF5kD4r6sU3eDJRFhH+FQ8YGq7u3ytupucRe1ULQkM3T2InOqYEgUg52i6d5YS6nodmQPXk3jv4IhExeZdTFV8ta/Dv8Al0Xa2qiyPPsAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left\\{-6, 2\\right\\}$"
      ],
      "text/plain": [
       "{-6, 2}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 解一元方程\n",
    "solveset((x+1)*(x+3)-15, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "58494a8d-044d-4a38-9093-ca389cbf2796",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE4AAAAWCAYAAABud6qHAAADsElEQVR4nO3YW4iVVRQH8N80hgVWjlFB0sWXIMkou0APY5NSGQPdewnKwC4PWQkhQZEcgigi7fZQRFCRD1EE1dB0oxq7YAkygnYnGmMsSS27OjZ2eVj7MMfvnPN95zJHJuoPm3UOe31rr+//rb3W2rurVCr5H83jgIL5K/EhfsKfOKXTDk0BlDCObXgRJ9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0Xa2qiyPPsAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left\\{-6, 2\\right\\}$"
      ],
      "text/plain": [
       "{-6, 2}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用Eq方法\n",
    "Equ=Eq((x+1)*(x+3), 15)\n",
    "solveset(Equ, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "540edbb9-8fa1-4b91-ad47-6d183b3472a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANEAAAAWCAYAAABe13njAAAGaUlEQVR4nO2bW4wURRSGvwWiEAk3iRCNZEMURERXREUDCASQiAYWxQcviDdMjCFiePHKqEExAUXUqKhxER7UZFGCgHc2iIIYdTQoCCSASFAUDIjh5ooPf3V26Kmq7p7p0WGcP+nUzpxT1fX39qlzqZqaTCZDFVVUUThaRcivA9YAe4FmoM6hNx/YBZyU2syqqKK0uAA4Ctzm0ckAR4CfgbeBXjYlnxGdDSwE+gKNwGNmsDAuBG4EZgJ/hmRPAB8B24EDwB7ga2A6cLJlrEmImO9qdsy3m5E94+F0Q844vodXLK4x8/gE2Gfut9ChO4nCOUP58E7CuZg+AYrl/SUyjEeB9o7+TcBsIAuMdc2tjWcCw4Aa4H5grkdvBnoAz1tkU4GvgA9o8VQDkYVPNn9vz9HPAg877jMYGA4sd8jHokVhkUN+OvAssB/3Q0sLDwDnmXv9BJzl0c1SOGcoH95JOBfTJ0AavB8HPgemICcRRpO5QEY3wIy1P1fJZ0RdTLveo9MLGAG8jDxNGB2Ag5bvZwD3AfcCd+Z8nzWXDatNO88hrwd2AystshrgVSNfBExzjJEWpqKXYjNwGbDCo5ulcM5QPryTcC6mT4A0eK8FNgB3oEjqb8/9NgD9gc6EjMgXzrU27RGPzi1mwm845DYDAnjTtGd6xs5FP+S1dgBLLfIOaMVegj30mWLkN5MfcpYCK4BNKIwoFFGc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gLx9+oeJwhvLlXUdyzkn6lIJ3kP9Hef5c5NmFz8scMm1nj85hROoiZCi5WAfchR5UV2SwHdGp7wxuAwJt4Nagh+bKmepNa9u19iFjxra59k7AuSiBjFO6j7qH66q19InDGcqXdzB+Es5J+pSC90SUh86KMU5gB3lH2XxGtMm0t6J/rEv3KbRD/EiMiaSJerTptSXFMQejMPbJFMdMG1Xe6aAdOgDdiFIOF05ETmIoKrrlHRDwhXPLkDcZg4wE5G2yIb2DqKI0DB0F+jcOeILCn7SxhGT7Xv8FqrzTQS3KPRs8OhlaSuTB57yT3j4jOoDi0OGIQHvcpxdWUnmHHKuobKxHRuFDEyok7EYFjaxNyWdEoLxoOf4fhVVRRaWiiZYf5TlR7E8hqqjif49/ALx3B33WDBc+AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left\\{\\left( \\frac{37}{4}, \\  \\frac{17}{4}, \\  \\frac{11}{4}\\right)\\right\\}$"
      ],
      "text/plain": [
       "{(37/4, 17/4, 11/4)}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linsolve([3*x+2*y+z-39, 2*x+3*y+z-34, x+2*y+3*z-26], (x, y, z))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "53618fd8-816b-4005-8591-9f7e9e8ee983",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANMAAAAWCAYAAABaIqneAAAFqElEQVR4nO3baYgdVRYH8F8b0YjiDg64RRGXccs4KgoqcY+4xHacLw4uqCCCOBEHRNwaxeWDu4gifojoBxWihrgLJjOO6ChCBDdcsF3jxNEhGjGu8cOph4/qV7fqVb33ujt5fyju676n6pz6n3vucu6tkbGxMUMMMURzrFdSfxpexkr8gtkFcvdhBTbumWXTC3/GGpzbw2eu65wOClV8N4af8AUew66dhFLB9Ec8gD2xENdlD8vjAJyOG/Bd0ux6OBV34AV8I178gT7oaaLzN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xYNBCCqH/k7mnZXHfPpY5OOEZMiTs5uKpNKU7PxNWZjhfEwjqP8TY7u9U9mThZdc5HMtmX8N/cc+pylPJdOwq5TAVTlZ3ohWL4PAN3VpCvg9mCoHbsnF3ECJpv2HvjW+mFaa91biYc/Lg4tpJHVZtSnO6UlTPEeqAT/mliQ2nKxyAwW3XO98f2uLXDc+pwVOa7TpgQH6lR54esnHAGqQ0/ihc6EH+qaES3GBM9UdE1Kye/OfYRi8RuUsxNdBKNf6ZImebRjU0pTsvsGjFx/6Mb3ZOJMdU5H83KTuulsud04ijluzxa8TAhm5kKpvey8hzRCxTJ3iJO5l5dwZBB4FAxRb15gDo3EgcqF4qj/k1t6iWnk8FHvzGK19XPmrajzHctbCg6uDkiSfdlXiA1zXtSpBSPF44lesplObnVYiPscHEcZrKPFi1WfZ+mV5glNrgXFNR3a1MvOZ0MPvqNogxzHcyS9h0x2l2V+zt/kNZIyWfrG4pU4B5ipzl1ImKIIdZWzMEh4jOPlxSkz1MjE7Fueiq7hhhiXcVSv38cWIjp/JnzEENMKfwGYmWnSZWB/sgAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left\\{\\left( -1, \\  1\\right), \\left( 2, \\  - \\frac{1}{2}\\right)\\right\\}$"
      ],
      "text/plain": [
       "{(-1, 1), (2, -1/2)}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 非线性系统\n",
    "nonlinsolve([x**2+4*y**2-5, x+2*y-1], x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "e2a63ddc-6c74-465c-b241-25eb8b832b2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACYAAAAWCAYAAACsR+4DAAAB+ElEQVR4nM3WT4hOURjH8c9rhMX4NyuRmiQhZZKUhYxZqVmYBRspCys7ZIXF3cgGCzayUtiQYkNW3p0/RRZE2QxRCguieTUYi3MutzvvPa+X+2Z+dXpu93nuc7733Oc89zSyLDMTNauDfzfu4SO+Y6iGOTNM4i2uY1W7oNmJBGtxCV9wFW9isqJ2YqsAvB7zcRl7EnmbmBef2YGl2NQN2DY0cBRnKmKORaDPeI3ViXxFsGa8foiN6I85fin1KQeifZaIOSh8igXY/wdQZT0XXn5x2ZFasb5oJxMxd/4Cpqg8d1/Z0an4/5tSYIuinejh/K1oF5YdVWANbMEUXvYICsajHS47ymDbcQoPsAHnTW8Rdeqi8OIncQXHMVgFdkjYwk9wtodQhN54QtgEu3CkCuyA8L3HsBK3tdkxNWoU5/AI6zBH7HHtauwTbuAalmFND8FGos3wVKE1pXZlXvQDiZh/Vd5Yx8uOVIPN6VPwY3HAkmg340K8fo/Diefz3N+6AZtK+HINYW/p3oo4CKueAqucK7UaX6Od9h8rKBN6XtUY7ACU526VHSmwF9Huw/IOsd1qrnDUGRY227tuwG4KvWwUr9R7UGzhvnAqOY0f5aBUjU0IjXZEaBn96vkLNIVi/4C7eNwuKAVGqLNbcdSlpt8HxUrN2GPPT1X9XBTfJfbDAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left\\{1\\right\\}$"
      ],
      "text/plain": [
       "{1}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7 解不等式\n",
    "#  3.7.1 解带有有理系数的有理不等式\n",
    "exp = [[((Poly(-x + 1), Poly(1, x)), '>='),((Poly(-x + 1), Poly(1, x)), '<=')]]\n",
    "solve_rational_inequalities(exp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ee6009a5-4b61-492c-beed-c8edba27a928",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJIAAAAVCAYAAACtzrfuAAAE2UlEQVR4nO3aeagVdRTA8Y+WpWlpmBGUGVQaVFaU2apZZv4RJRXRHxYVQSuVUNFKzyKLNqMVgsKooAIxaQ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6f2kk/y0W4vJPI5aSZLiKlB+WvFrUwekGOLM1S4eNNFTmlNFeIVa1KPq5M743MZZZyHXUp2SOS2TgeR+GTFvX5cPLLMl8osq+N8yVpasb/V0k/54hjhdvFtrwUY8X2uUw87DwmiZzO3JL24Tw8K1IG88TKMlqE8++IM6wqlOm93rlU1RGRbpmS/L1dUh4ojJFwOy4qa6RP5jOSzbBSRGhjKwyiO3hbZHtHKI90hot0w2Thg6wSeavpBfcOxtd4zgblljEGVwnfb5A4r5ojDn/XVGyjit7rmUs9OuoQGfIiPherYZYXMF4SEGVXpD9EwnAG9kkG1JMYIt74W1QLl1fitDraP0X4ZjfXcc9ikQ9rhip6rzqXIerTUYcNB7ENk3cwORNfCOvvaRwqwulbW9D2AFwmtplXWtB+GV2l91bqKP090vi0IO8zkt/EIeAE4cj1pG+SnlCcb2mWnXCvDb5Bu+kqvbdSR7XvkTYi6yP10ktDlH1z00svlfgX00RDDMx9dc4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, 0\\right) \\cup \\left(0, 1\\right]$"
      ],
      "text/plain": [
       "(-∞, 0) ∪ (0, 1]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve_rational_inequalities([[\n",
    "((Poly(x), Poly(1, x)), '!='),\n",
    "((Poly(-x + 1), Poly(1, x)), '>=')]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "acac93bf-d703-405e-b992-254f2a344523",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQ4AAAAVCAYAAAC31wBJAAAE20lEQVR4nO3cf4hlYxzH8dcMf1grO7WUUpok/mA1ElEsm8U/YsIf/mBJCiXZQpFyl0TIKj9TahSFEvLrD9m1lrLrRxNp5ecssVrLhuxufq0/nntzd/bMuee58zznXjP3Xaczc54f9/v9fO/znfOc55kz1Gg0DBgwYEAMw20/n47dbcenM7R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EvhW+44jov3u6pf3fRNXk076Tkunx7MfrxQrk8hsYljK1bgoYh2qekkwhL8JixH9ZIxXDrt2uHNg3BLOf0Ls0j4kr2Mbwv6TOFb7jiOife7ql/d9J1b0056jsmnRxU6jZdO+hQSs3P0D2GzyYk4LqJdnYzgWDyqd0tkLRrCvHGmY7SgzQphLnpvQdmINL7ljmNDnN8jqvsV2zf5Ne2kZ6zNKWyKoUyfGSlKHLea+X0cq/GNsOmkHzkVf+K+XhvSBQtwk/AX7O2C8pS+9VMcc8asLk1T6lnnd7iTPu3v4zitvaB9qjIl/N99i20FHe0S3juwTNhu22/bll/S2zX12TCKx/w3951OSt/6KY45YzaqHk1T6lnnd3hUuT6t93HsxdDg1YEDBgyIJdc7HwYMGDCH+RcAncoCCx5IVwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left(-\\infty, -1\\right), \\  \\left(-1, 1\\right), \\  \\left(1, \\infty\\right)\\right]$"
      ],
      "text/plain": [
       "[(-∞, -1), (-1, 1), (1, ∞)]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7.2 解带有理数系数的多项不等式\n",
    "from sympy.solvers.inequalities import solve_poly_inequality\n",
    "solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '!=')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "9c0289c1-32ed-4f94-b59a-f81668f408a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADgAAAAVCAYAAAATtC32AAACt0lEQVR4nN3Yb6jOZxgH8M85vMDRKFNKLUnzYojWRKFWZ/NGJvbCC/+SQmlRo5QXJxJty1HLSCnKipWQmRdC/pX/KenIlkKi419oTbbhxfX7ze/cfk+H8zyelm/d3c9zXffv7vv9Xdd9XffzNLS0tHif0VjBvg3taKojl2rwKV5gXuooE/gZZmIt/izYv8aPOI7H2Ybba820iziPPViF3kVHmcDVQsDGxL4CizASt2rNsAZYgwH4pmhMBX6MZvyCvxLfksz/ARa+G45V4QyuYL6CrlTgXDRgZ8kGR/C7SM3/K3bgI3yRG1KBzfgXp+pIKscMXBeZsx29MvvnOIeHOCAEVMLJbC4V2CTOV5uOxaUeGI71WIqvMBa78Qn2C4FTcBW7RJaV4Ww2T8gN3QvOgeiG2zWj/eZYgpXi7MNkXMAhIXBBZj+K0yKqh0v2eYSnClEuRrBfNj+sFeu3wDBBPsdlbMGHWJasPS4iWwkPsufQUWBeNXt0mWZ1SIvXNZFR/UvWVUpR6KnQAYoC27O5n/qjDeMK3/tgMe7hOx0FTRARLkMj+nqlpcMZvI27GFot2y6gFQeFoDvisnFdnL3TIl1/wlSRYWXnj+DegIu5oRjBFzgm8ndIjYhvzfad08m6iyJi3+M33BdiLmGSiNoZ0camq9yLx2TzkdzQPVmwC9MwEX8kvinZIK5ERDnfmn2+h2+TZ/IX+E8FQkX8nI0Uh8ULb8TzTvb4UvTxvbmhTGA7ZmFD4huJ2YltcDaIlEoFDscTUeqrRWfi+ogA/IqbuTG9yTwTDXc0RiW+FpHflcagZH1fjMAm9Wk9s8T5/KFoLPs10YobovFWg/H4G+uq3OdN0BPLRQaeKDrSFCVuAjPFbaFJ169t+9Svpw7CZq/qwX8oE0hU02Pvjk/N0SaO0Guo9JfFe4OXFKyHh0Xs5mMAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(1, \\infty\\right)$"
      ],
      "text/plain": [
       "(1, ∞)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve_rational_inequalities([[((Poly(-x + 1), Poly(1, x)), '!='), ((Poly(-x + 1), Poly(1, x)), '<=')]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "ad137dec-a4dd-41c4-b9a9-b6e64e1ef427",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhE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I5XNx4hRuT2vKI159+BdEVMcn0jwIu3irXtATAR+EkKvwwXizVstUnaXK7+qsyirv6pGMvaGO4TB14qRKqXjEqPWepFqGl9ou12MRCly8n3RY5Ge2aFd9TaHM7JyeV5RXB5eIlZUzhPr3LXguewosky8NAN1TZiXkr9wjc6hXilm0bvFRGN2mWs6hJGrYZZIVa0RM/QtwpEn4BM8UuX9+6pHb+xQrc3h3EzGV/KKcs7bKfJ7j/VAqFqwLyXG4TeRZmkkx2blIDGylGOl6p13BSaJ0XGi2JzyA+aLzSq9mYSWo696pLTDvmw+QuSCXxVL1ui6wvanSCifjpMTCJWakWLUWahySq9etIkYrLujNVFfa0R+9BCRYThOpLJ+SXDvNr3XY6T62mGGiIcfLK0st91tgdhZNLcOQvWWSSItNL/RgvSB0v28Zzeg/zul289bTzsME5uFlohtmnsptyVyl0hMTxZLxvvTnt6lKueh93fy/bz1pqPQb4pJZT3tcAyeVCb8GtD/b0D9NCuN3iXfTz995l9JaGYfJ8hGygAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, -2\\right] \\cup \\left[2, \\infty\\right)$"
      ],
      "text/plain": [
       "(-∞, -2] ∪ [2, ∞)"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7.3 解实数单变量不等式\n",
    "solve_univariate_inequality(x**2 >= 4, x, relational=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "45aef3c2-9e90-4da6-955d-0e9314ae11d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 2    \n",
      "x  ≥ 4\n"
     ]
    }
   ],
   "source": [
    "pprint(x**2 >= 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "9eceec23-d770-402d-9c68-19e7e7a6b39d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "解方程: \n",
      " 3      2          \n",
      "x  + 2⋅x  - 3⋅x ≥ 4\n",
      "获得: \n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAAeCAYAAADdPDLPAAAH10lEQVR4nO2daYwURRSAvwXBRQksKmo0mkhMPBZ0o0SFyCqXR0TYVSEmom7UGI1GJV7xStYLb1lDPCNxTTRREzXGFdAoi0KiQdRV8ER0vS9Wghdeq/54NTLb29NTtdPd1T28L+n0TFdNz6s3r151Vb2qqWltbUVRFEVRohgUcm0WsBZ4HHgMGJ+qRIqSPOchtr0UsfWhHmTQeqZkkZJ1YZuQa6OAesR4f09Kogj+9fCdQWp8C6Akyt3maAEeIvyhKWl817NqZ3vgF88y5NGPNAA7IA9SffBRSaI4GDgXUbLPQ1GU/HIwcCrqRwbCKmA6cGAwIWuNxXHAc76FUBQl16gfqYzrgHuAwcUXs9ZY7Al84VsIRVFyjfqRytiEzKe1FF/MUmOxC/CtbyEURck16kfiYRFwLVBbuJClxuJYYLFvIRRFyTXqR+JhFTAMmFm4kKXG4lDgNd9CKIqSa9SPxMdbwEmFN1lpLIYAvcA/vgVRFCW3qB+JlzeBIwpvstJYHA6sjEg/CVgIrAB+QtZiPFIib4tJjzp6LeXaxeRdCOwInAU8DXwMbEYmglYCZ+JPly66CZKH8tlSiR6qja3VJuL0IxCfL8mrTj8DdkbkD12U54OjgVsi0q9G4n5/Ab4E9o3I24VMzIQxCZgCLLGUaxby4z0FzAbuBb4BOoHPESWeADyIjJXOJv1FhS66CZKH8tlSiR6qja3VJuL0IxCfL8mrTjeZ817Ad2k3FoPM8Xfg+ihgY8Tn5iE/7sdIt6gzIm+XOcJ41ZwfKCNngWagB3gFWWQzE4nfLu7mXolMBp2I/OBPWt47Llx0EyQP5bOlEj3Y0AjMQZ4OPwxJnwscBlyKPC36JA820YKsnp8MLHf8bBp+BOLzJXmtZz+Zcx2k2+UZhUQpnBK4PgZYX+azncA6KmttxyGV+SvsFuyMQJ4cnkW6kMvM6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uQSai3kCeBDbEIGPaxFm+duQppSU+8TLL+8j471xkzUUxVyHDLI+nLFNc5NXm0/Ij4O5L4tZpO3Z1rQvpSdyG6KUHGQ5bg8zxNCKL/6YBJ1N6zckZwI0U9aB8bfexGNnR8EvL/E3mANjVnCewZSJsA3BJyOcK3UbbFds15nteRWK5izkdiTLoRbrAF4R8vhu7ybk4acJeN3GXr/CwkYX1F00MzEZcOB+JgnkdiS75AWk4GoC3kdXdWaAJfzaRJmn5EXDzJUno1KWuPWqOIMuQSetBRG+2uDuwGzKf9D++GoseZFm7LQ2IkosZYw6QblbwR94PGbtzmdgej6zQbQtJ28ucByMtdxgvk37FacBeN3GXbxzwM9n4C8sG3G3EleXInkDXILY1HLGvO4HrSWfc3IYG/NlEmqThR8DdlySh0zjrWrldeW9CNjXsk6+mtbU1mLEFCWsbRnaMPy3mI1EVY+gbNVAtxFm+OqSy3kH/kLy80II/W/f53cVUu837IG6d1pFeXZuEdCL67ZsV1rPYiIzNPoyMZ92OrPrbGmhGhhOqtdLEWb5JSJjonTHcK23OQ+SvQ2zdx/8fZKWeVbvN+yBunaZZ11ZSYh4jrGehKIqiKH3I0h9tKIqiKBlFGwtFURSlLNpYKIqiKGX5D5uH+zQ6+nFDAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[- \\frac{\\sqrt{17}}{2} - \\frac{1}{2}, -1\\right] \\cup \\left[- \\frac{1}{2} + \\frac{\\sqrt{17}}{2}, \\infty\\right)$"
      ],
      "text/plain": [
       "⎡  √17   1    ⎤   ⎡  1   √17   ⎞\n",
       "⎢- ─── - ─, -1⎥ ∪ ⎢- ─ + ───, ∞⎟\n",
       "⎣   2    2    ⎦   ⎣  2    2    ⎠"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 解不等式\n",
    "print('解方程: ')\n",
    "pprint(x**3+2*x**2 -3*x>= 4)\n",
    "print('获得: ')\n",
    "solve_univariate_inequality(x**3+2*x**2 -3*x>= 4, x, relational=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e9e23a49-80c4-4075-9d98-6665c51ae040",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALEAAAAeCAYAAABjY//+AAAFu0lEQVR4nO3cd6gcVRTA4S9FTVTU2FEUDIIlBoMGLJhYYiwY0zQi2B4qoiCi2FAUothrJGDDYAQFFVTEEmtiCViwPLuYRGOPkhhii6hP/ePMxs1m3u7Mc3f2bZwfDHf23jsz5509c++55559A6ZPn66kpJMZmFI3Ce/jAdyP0YVKVFKyJuvWaxycUjcMI4Tx/tYKif7n/N1uATCg3QLkZBQ2xVNpjWkjcUnr2BNnCCNq59FpvI7x2D2tsTTiYjkCT7RbiA7lctyKQbUNpREXy/b4st1CdCgrxFqtq7ahNOLi2ApL2i1EhzMLl2FIdWVpxMVxOJ5stxAdzusYionVlaURF8deeLXdQqwFvI2jqytKIy6GddCDv9otyFrAW9i/uqJoIz4aM/EyfhQx03szXruVMISZ2Ayn4hEsxErh+M/HKfrfy7mfkK038uilK2mvd/RklKsTdfo5thSyI32zo5VcImJ9P+Mr7Jzj2klCkQ9jGm7Dt5iHL8QfNRV3Cf9zmv6xsQCH4to67Xn00i0WN2mMwUGYk1GuTtTpiqTcAd9RvBGfI76khWJKmJfj2ilYhpdEwH6iiLlWT9EXC+f/KKH8h3LK14W7cSBeyHktYRAD8WdN/TAsr3NdHr10J0caryTlnQ3krFCETpvNj0m5SaWi6CliHhbI/zZvJEaYx8T0Nzc5r/Uxl+D25PyAPkvZN4aJ6MNxNfXDsajBtX3VSzUjsTe+lm1DpRN0msavSbkqzNZf/JxGTBBJII9k6PtHUtaOhq1mhJjeJtTUT1DMLt1pSTlLNp+4HTo9Xvi0K4XPv35SfyDeELPVHLEp1BsbJuXKSkWnGPEU/IJnGvQbjBOT89RkkRYyH1fgEBGNqLArPmjxs4cKA+kR/msWitbpSMzA+cIX30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",
      "text/latex": [
       "$\\displaystyle \\left[- \\frac{1}{2} + \\frac{\\sqrt{17}}{2}, \\infty\\right)$"
      ],
      "text/plain": [
       "⎡  1   √17   ⎞\n",
       "⎢- ─ + ───, ∞⎟\n",
       "⎣  2    2    ⎠"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "domain = Interval(0, S.Infinity)\n",
    "solve_univariate_inequality(x**3+2*x**2 -3*x>= 4, x, False, domain)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c41751f4-3c56-48c6-8527-96c93055b1cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALEAAAAeCAYAAABjY//+AAAFu0lEQVR4nO3cd6gcVRTA4S9FTVTU2FEUDIIlBoMGLJhYYiwY0zQi2B4qoiCi2FAUothrJGDDYAQFFVTEEmtiCViwPLuYRGOPkhhii6hP/ePMxs1m3u7Mc3f2bZwfDHf23jsz5509c++55559A6ZPn66kpJMZmFI3Ce/jAdyP0YVKVFKyJuvWaxycUjcMI4Tx/tYKif7n/N1uATCg3QLkZBQ2xVNpjWkjcUnr2BNnCCNq59FpvI7x2D2tsTTiYjkCT7RbiA7lctyKQbUNpREXy/b4st1CdCgrxFqtq7ahNOLi2ApL2i1EhzMLl2FIdWVpxMVxOJ5stxAdzusYionVlaURF8deeLXdQqwFvI2jqytKIy6GddCDv9otyFrAW9i/uqJoIz4aM/EyfhQx03szXruVMISZ2Ayn4hEsxErh+M/HKfrfy7mfkK038uilK2mvd/RklKsTdfo5thSyI32zo5VcImJ9P+Mr7Jzj2klCkQ9jGm7Dt5iHL8QfNRV3Cf9zmv6xsQCH4to67Xn00i0WN2mMwUGYk1GuTtTpiqTcAd9RvBGfI76khWJKmJfj2ilYhpdEwH6iiLlWT9EXC+f/KKH8h3LK14W7cSBeyHktYRAD8WdN/TAsr3NdHr10J0caryTlnQ3krFCETpvNj0m5SaWi6Cli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2KbNyijZ9VJhF+Fj5lnQNVunI/GT5m3m1Mvyu1okIq3RZ0DK/53oEqGmodr7a+erxMp+uNVXriV9p5k63US8rDdaM0TWbMaIATc1pyRtJF4uYnj3CL/kBrGbUjRT8I7SgJtJM3U6RmxH39SEezVivjp5JWlG/Kh0p79odmm3AGshzdTpY2p+69ZC6iZG9ffoRElJQ0ojLul4SiMu6Xj+ASbPjHfFeyVNAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[- \\frac{1}{2} + \\frac{\\sqrt{17}}{2}, \\infty\\right)$"
      ],
      "text/plain": [
       "⎡  1   √17   ⎞\n",
       "⎢- ─ + ───, ∞⎟\n",
       "⎣  2    2    ⎠"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "domain = Interval(0, S.Infinity)\n",
    "solve_univariate_inequality(x**3+2*x**2 -3*x>= 4, x, False, domain)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "73443662-e343-4aa5-a1fc-ce0e07f73f83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIgAAAAVCAYAAACdQqbPAAAE/ElEQVR4nO3aZ6hcRRQH8F+MLUTJsyLYImoULKwNRY0ajVEURBTxg8YOYhcECyJGxfLB3rER8YsGg4oFC/auiLHGjqioxBq7WD+cWb25e2ff3bv7XkTeH5azzNmZOee/Z87MnHvHzZo1yxjGkMMSmfabsQATR9GWutgCf+GIxWzHf5mjXpHltCpAtsJMXIAfS7o1cBM+xa/4EJdihYGZOjxewp04B8uN4rxFdONoJLCS+PPuwHv4GQvxFA6XX+h1keW0auBz8R2uKbWvmwY6FC/gEnyAE/BscmK0cD5Ww/GjOGcROY5GCvvhemyN58WinIuNcQPmYFyfc1RyWg6QKZieJvy5pLsaq6YB9sap2FkEygaCtNHCC3gLR6q3enbAlcLOKhyY9BNqjNWNo5HCO9hLZPADcBoOw4b4GPtinz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gXWSHC/OIFV43KIBMhBOx1W8D3IazhP71cvDGN4NQ/gKF4nizCBxnMhkU0VRaLQxCI6GjBw/TVDJadWDrkvwkcgU/WCquDZe3Oc4ZUwQf9Bciyc4GAxHI8VPE2Q5LW8xRKqdKc4WEzV/3+Fu+XpBP5iM6/ybThcHBsHRSPHTBJNlOK3aYsYwhn/Q75tIY/if42+w7IQ/85JKeAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left(0, \\pi\\right) \\cup \\left(\\pi, 2 \\pi\\right)$"
      ],
      "text/plain": [
       "(0, π) ∪ (π, 2⋅π)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 解三角不等式\n",
    "solve_univariate_inequality(sin(x)**2> 0, x, relational=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "31bffd19-7d86-4bdd-bd3e-6e359af18f9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "化简: \n",
      " 2    \n",
      "x  ≤ 0\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADMAAAASCAYAAAD2Uea5AAACG0lEQVR4nN3WT2jOcRwH8NdmJ3/aXOSgrMZ2dZApHJBNLsRBqYW4oHgiNf8ySRHlXxwcRLtpB8qBRQ4iBwdKsbFSE0orkhUHHD6/H79+7WfPtD1be9fT5+n9+fT0/nw//56qjo4OkwXV4y2gDMzBVbzHd7zFOczMB9ZUUtV/oAGPMQu38AqLsAersQQDafBEr8xlkchurEM7VuAsmnAiG5xPphu/sCHHV+Fa4js5yoKL0IAW0VaXcr6j+IY2TEvJfDL78RPHMSXDn8FmXBGvUwksT2x3oimLr3iEqVickvmZeY5OIbxNVOMg9uIGdgwjoIS6EQh+hpsFvqbE9hb4X4vKNeI+Qy+AI9goSjld9OVdkVz+hfIoYe4wMVlcV5xMbWK/FPhTvi4lhkqmX6y+dlwU22Q9fpQhrr6MmDFD0Tb7lPm+DYMV0JJH+vK1Bf6U/5wSQ1Vmkxj4j5gtdvpws5KiZPRmpiexjQX++Yn9M1P5ZNaIoX+BlXiI7aLtegyPktGbmQeJbREdlJ3XGeJgDuJJSmbbbCm68A6totUOi4RPlSmuXtykcj9b/vFbfWIt12NXzndM3JdOcW/wtzILcFv06Sp8SPguPMVaLBOVqiR2igV0QXTKSzSLG9SLQ9ngaszDHXHdW8WLZHEgsafHTHIx+rBQtH4z9ol/BufFsRzIBtfgjRj0ItwTLTFe6MfWcgIn+h/NEWFSJfMbnLVn7svK+4MAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x = 0$"
      ],
      "text/plain": [
       "x = 0"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7.4 化简带有有理系数的有理数多项式\n",
    "from sympy import Poly, Symbol\n",
    "from sympy.solvers.inequalities import reduce_rational_inequalities\n",
    "x = Symbol('x', real=True)\n",
    "print('化简: ')\n",
    "pprint(x**2 <= 0)\n",
    "reduce_rational_inequalities([[x**2 <= 0]], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "641d9e2e-adbf-4583-b107-f875794510ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "化简: \n",
      "x + 2 > 0\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAASCAYAAAANBhNmAAACoElEQVR4nO3YS2hUZxQH8F9MloKIi7aCaLWgBSmCLhQUlKBiwBQUqVRthLgJiq9S4hODIiQoVKnQUgQFmwo+6KKNVAVFFBei4AtRMfWJpo1Y3Ghp1bg4N3ZynSQz8SYg5A/DvZzvO+d88//Oa6akrq5OPzpiQIa2hmAJfsEtPMdTnEF1xr56FWUZ2pqH7/EIJ3EPH2AOdmNWsqctQ5+9gixJuYlKNOFVjnwdzmGuIOhwhj4HYhQuZWgz05A+gV91JARa8EPyPjUDP2WoQCP+xKoCdI6JCJ2bkpdgb7JW3y7sqzz/L3m+eAcbk7BLpGcTvhD16ucCdL8Rl7UFpTny7ajCj1jTLuwLUsrwVfL+e5G6o7EZzTiLpaKIL8dQzBRR0B0uYR8+xaJEtg6rcQA16QP3NuoxFkdwtID9H2E+FmB8IruK9diP2z08x0YRXZtELdqanGeRVMqnSbmD4UU4asTCLtaX42tc9/8NdYezGIG/0SDS43IRZ+oM97FDpMl3iZ85+De9MU1KM/4pwtHDLtaWYSeuoRxPCrR5RZAyWKTHEzHv3C3iXJ2hNee9Gs/ybUqTUp6BY1iJb0XYl+OvInQrMVKkzwIRLfXiZvfjYJH22vGlKKwt+BArpGpJO3qj0NYKQi5imp59gT9EpxiDCSLsR4ru81DUgsUYVKC9CtF6r+Iz3BDT9+h8m7MmZaO41QsiQh5nYPOC6BLDMAM/ifa8R8wptd3oT8YhPBDp2IoNIksa8ilk2X2qRPt8idOiyKZxR9xYT/ASx5NPDWaLIj+qC51x+E3UpOlixiFIOo/PMSU57xtkScrHybNU1JR8OKXnpOTiuZgvDug4jOXiEzEXtYkIaU6trxUEb8PE3IWS/r8O3sZ783O+L9FPSh68BjsDj5boLOmMAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle -2 < x$"
      ],
      "text/plain": [
       "-2 < x"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print('化简: ')\n",
    "pprint(x + 2 > 0)\n",
    "reduce_rational_inequalities([[x + 2 > 0]], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "a18fa60b-0d33-4f98-8818-9ce5a4c87afb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x + 2 > 0\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAASCAYAAAANBhNmAAACoElEQVR4nO3YS2hUZxQH8F9MloKIi7aCaLWgBSmCLhQUlKBiwBQUqVRthLgJiq9S4hODIiQoVKnQUgQFmwo+6KKNVAVFFBei4AtRMfWJpo1Y3Ghp1bg4N3ZynSQz8SYg5A/DvZzvO+d88//Oa6akrq5OPzpiQIa2hmAJfsEtPMdTnEF1xr56FWUZ2pqH7/EIJ3EPH2AOdmNWsqctQ5+9gixJuYlKNOFVjnwdzmGuIOhwhj4HYhQuZWgz05A+gV91JARa8EPyPjUDP2WoQCP+xKoCdI6JCJ2bkpdgb7JW3y7sqzz/L3m+eAcbk7BLpGcTvhD16ucCdL8Rl7UFpTny7ajCj1jTLuwLUsrwVfL+e5G6o7EZzTiLpaKIL8dQzBRR0B0uYR8+xaJEtg6rcQA16QP3NuoxFkdwtID9H2E+FmB8IruK9diP2z08x0YRXZtELdqanGeRVMqnSbmD4UU4asTCLtaX42tc9/8NdYezGIG/0SDS43IRZ+oM97FDpMl3iZ85+De9MU1KM/4pwtHDLtaWYSeuoRxPCrR5RZAyWKTHEzHv3C3iXJ2hNee9Gs/ybUqTUp6BY1iJb0XYl+OvInQrMVKkzwIRLfXiZvfjYJH22vGlKKwt+BArpGpJO3qj0NYKQi5imp59gT9EpxiDCSLsR4ru81DUgsUYVKC9CtF6r+Iz3BDT9+h8m7MmZaO41QsiQh5nYPOC6BLDMAM/ifa8R8wptd3oT8YhPBDp2IoNIksa8ilk2X2qRPt8idOiyKZxR9xYT/ASx5NPDWaLIj+qC51x+E3UpOlixiFIOo/PMSU57xtkScrHybNU1JR8OKXnpOTiuZgvDug4jOXiEzEXtYkIaU6trxUEb8PE3IWS/r8O3sZ783O+L9FPSh68BjsDj5boLOmMAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle -2 < x$"
      ],
      "text/plain": [
       "-2 < x"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pprint(x + 2 > 0)\n",
    "reduce_rational_inequalities([[x + 2 > 0]], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "a7d2b3ca-a58d-4aee-bbb1-2541f8302a35",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAASCAYAAAANBhNmAAACoElEQVR4nO3YS2hUZxQH8F9MloKIi7aCaLWgBSmCLhQUlKBiwBQUqVRthLgJiq9S4hODIiQoVKnQUgQFmwo+6KKNVAVFFBei4AtRMfWJpo1Y3Ghp1bg4N3ZynSQz8SYg5A/DvZzvO+d88//Oa6akrq5OPzpiQIa2hmAJfsEtPMdTnEF1xr56FWUZ2pqH7/EIJ3EPH2AOdmNWsqctQ5+9gixJuYlKNOFVjnwdzmGuIOhwhj4HYhQuZWgz05A+gV91JARa8EPyPjUDP2WoQCP+xKoCdI6JCJ2bkpdgb7JW3y7sqzz/L3m+eAcbk7BLpGcTvhD16ucCdL8Rl7UFpTny7ajCj1jTLuwLUsrwVfL+e5G6o7EZzTiLpaKIL8dQzBRR0B0uYR8+xaJEtg6rcQA16QP3NuoxFkdwtID9H2E+FmB8IruK9diP2z08x0YRXZtELdqanGeRVMqnSbmD4UU4asTCLtaX42tc9/8NdYezGIG/0SDS43IRZ+oM97FDpMl3iZ85+De9MU1KM/4pwtHDLtaWYSeuoRxPCrR5RZAyWKTHEzHv3C3iXJ2hNee9Gs/ybUqTUp6BY1iJb0XYl+OvInQrMVKkzwIRLfXiZvfjYJH22vGlKKwt+BArpGpJO3qj0NYKQi5imp59gT9EpxiDCSLsR4ru81DUgsUYVKC9CtF6r+Iz3BDT9+h8m7MmZaO41QsiQh5nYPOC6BLDMAM/ifa8R8wptd3oT8YhPBDp2IoNIksa8ilk2X2qRPt8idOiyKZxR9xYT/ASx5NPDWaLIj+qC51x+E3UpOlixiFIOo/PMSU57xtkScrHybNU1JR8OKXnpOTiuZgvDug4jOXiEzEXtYkIaU6trxUEb8PE3IWS/r8O3sZ783O+L9FPSh68BjsDj5boLOmMAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle -2 < x$"
      ],
      "text/plain": [
       "-2 < x"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reduce_rational_inequalities([[(x + 2, \">\")]], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "08b72d2e-e924-4d35-81bb-d18e451e483a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEsAAAASCAYAAAATzyPVAAACEklEQVR4nO3YT4hNYRjH8c+Yu7RQFuyMsrSwtKDUNIkFZZJSjBobpXEjYTKZSI0oM1mQLIiViPInf4pEFqJGScjUhJiQskH+jcVzLtdxNedo7tzB/dbpvD3nOed9zq/n/d33nobu7m51sjGh1gXUmMlYjVN4jPd4ixtol9KnMNbVjTOWYj9e4CqeYAqW4BAWJDnD1MV6hEU4h69l8U7cQqsQ7iS/LsNLQsXWVLwBh5NrPaNdcQ25gjN+FgqGcCAZzysF02JtTG7cgcay+B604SA2j16t45pPyflzKZBehndxVAizQnRTJ9bjONaMMEERk3IU1I/TOfLHigJWJuML5cE0XViGbZiInbgoxEu3a5oipuUo6ojxKVYPZuK8eHdU3jo8RS+asA83hcl9zDBJk/C3rMeqnC8xKHwz63Es5/OhAxvwQDTId373a/iqbNyOd38waTUYwIcc+c9zPn8t+nAfzXhTfrGSWMuFoQ9hKtYZ2atKFFXXs5pz5OaliL24l8zzMp2QFmuhMPXSDdfFDrcXDzNO+Dd61ibhU/1owetKSeWeNQcn8AzzxVLcKgTdlXHSJtX1rGrQJYS6IxqkolD86KxZOCv+F7WI7T8h3m0sxlzRaf8SbdiOL+LdOirkDIrVpoAZYi8xLDpqIJW8BZexG7OrUHAtmZ6cG4WFVOKaRKyG+iea7Pzvn2hyURcrB98AAvd3n90W6Y8AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x = -2$"
      ],
      "text/plain": [
       "x = -2"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reduce_rational_inequalities([[x + 2]], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "18f8f7d7-b8cc-4740-be92-c85dee4791c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHoAAAASCAYAAACU/srTAAAEOUlEQVR4nO3Ze2hWdRgH8M/mRNaFkDKtkEoFM+iGUUlirtZFK7tYJHYxsIwwzJJcRJdVUBlaWUEXJIO0oAtmZdQKLYqFhpU1uphtXaysVWCBhaX1x3NePTtue8/r3o3QfWH8zn6Xc77neX7n+zzP762or6/Xi10flanrfXEFlmAd/sRGvIupmbm9+H/gTDRgvfBXM57DqOzEqtT1hXgEP2IFvsVAnI8FGJfM+bcbifciP+ZgNn7Fi/gFw3AOJuIyLCpMrkhJ98nYE8uwNXXDQViFwbgAL5SJ6F4YijVlul8eVGIe+mIlnurBZ5eCYrYZhO/RiiPxc2qsBsvRgiGFzrQcL8fL2joZNuDR5HrszvHehiqMx2L8hOtyrGkQKjIx01+BJ5Oxe3I+/3jMxHTcnnNNd/BoD6XY5mDhu5XaOplQ4z8wIN2ZN+7+nbT/5JyfxSg8LMLCMlwkYv/TOdbeIDbfneiT6p+LKXgcN+bkMSFpt+JQHJFzXbl5pLEztvkSm3Ec9suMjcHeeDPdmcfRVULv4bUc8wsYjjvwFRrFV7QOM3AgThdfSTGsERI7ApcmfTfhejyLq0vgVHD0Y5n/86CcPLpqm99QJ3KoT8Umuzvh0YA3cFV6QUWO8mouZuFVkeV1hgMwCRdjZNLXhGeSv5ZiD+sAg7FWhJF5eAivC0dtznmPIcKwH2IyPhPSd0IP8egO25yLJ9A/1bcOt8koQrEveoZw8ue27+LO0Ij7hFHn4Cghj3fZeSfDd3gAhwjjNopqIK+TiWwUlor3WSukb2AP8Si3bWbjeZEfDBWJ9EhRYi3GvenJnTn6GswX0lAj5KIYPkna/kJ+zhCJQznQmrqeik0lri/I9NJUW4Gze4hHOW0zVmyWl0ToaE54fIDzREY+SwdZdxozxY5tEk7ekJPABLG7bkV1QqZFJBfTsX/+d2mDySKEFHhcW+L6/hiNb/BR0ldweClxuis8ymmbs5J2RTtjm0Q5XIljCp3tOboO9wuD1NgxfS+GZpGZHoZjhdQNEZnlDyKmXY59ct5vvJCnJlEzfiFO8IaXwGm8SCqXpvreE+9WKwzfEzzKZZt+STugg/FC/7aQknX0LaIWXI1TxGlLV7BaSMtgnCZOakZhoagV64qsHy3i0Hohd624WThtTgk8srJNlEqvCCfX9hCPNLpim3eSdhoOyoyNw4n4S+QFaJt1TxE7douQ7Y3tPODrZE5XUC3i4iVCAqd1MO9ovCXOcEeLjLmA98UXMcb2l+4IfcWG3SLkMX0WMEE4fwGu7GYeeZDXNpXi668VhyNLkvkjhKxXiPA7v7Ag7eh6kZZ3hrd1/XQsjT7CAVkME7GrH07Cx5nxWlEr5imPThW15SI7Vg7VYhP8LurX7Dl+OXmUio5sU0BfEdsn4XDsIRLmVXhQpg7PU0f3YhdA70+Puwl6Hb2b4D91EzOH7V2nKQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 2 < x \\wedge x < 8$"
      ],
      "text/plain": [
       "2 < x ∧ x < 8"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7.5 化简带有绝对值的不等式\n",
    "from sympy import Abs, Symbol\n",
    "from sympy.solvers.inequalities import reduce_abs_inequality\n",
    "\n",
    "x = Symbol('x', real=True)\n",
    "reduce_abs_inequality(Abs(x - 5) - 3, '<', x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "a55d74fb-36f4-42ec-8d3e-c5c3e07866f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAL4AAAAUCAYAAAAz84cVAAAGMUlEQVR4nO3ae6wdVRUH4O+2F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{3} < x \\wedge x < \\frac{7}{3}$"
      ],
      "text/plain": [
       "-19/3 < x ∧ x < 7/3"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "d85151bb-c6b7-4bc7-9248-dd18858a6479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(│3⋅x - 5│ - 7, <), (│x + 25│ - 13, >)]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAAVCAYAAABPGzn7AAAJqElEQVR4nO2de7QVVR3HP/dyQRALTc0bhsHNJFpahBmxIoQEScqLlq3MNCzLXsi6BUov8qYLhVYmqK2oqNAsK1OCKwVYUgkoEiDgAkPE6ysglRaWQfnqj+8eztxhz5k9Z/acc+zOZ62z5jJn9pzf+T32/u3f3nNoaG9vp6CgoKCg+9EYc/5G4O9A3yrKUlBQLU4GXgY+VWtBCgpqiW0AOAW4AJgFPOf5884BrgfuBp5FQXhzmeuPREG6ENgO7AP2AiuBi4gfwApeucwG/gA8juy9B9gAXI78IY73A8uBJ0y7HcCtwAjLteuA3wBXAod5krteyBIzxwAvohgNqNQeBfXB+aiftSY8NmeYiTrn7+UgzNeBycBQ4EmH6z8M/BAYDqwB5gC3AScC84FfAQ05yFlQO76IZp53AnOBnwEvAO3AJmCApc1s4A5gGLDUtFsPTARWoSCIcjXQDEzxKn3tyRIzE1GfcHvoXCX2KKgPBgA3AP+Ku6AhsgZwAvAgcpSLcxBoDMrQtgOnAiuQQ9kCFOC9yPmWAC+FzjcD96EveA5ycB8cBrwR2OjpfnG8HWVjfwR+bXl/NtATmIpG7nqgWrrpDey3nJ8JfBUlJp8PnW9GycRTwFtR6TJgDHAX8AjQYrnnVuBQYBBd/SuJRuAaZKM1wE9TtM2bLDHzO1QBCGYCkN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/DXvZtI709KsXFz4bix+992NKXLEn4iL92tEPpoCeBowNALxQInWhF2TeBIHE8StcHo5KuB5VRRmeQKUoP7FPa41EgHIICIPoATFDPX0Mps3ThcJQ5NOFWe8xLDhfidOOLE4HPooB6PdLNc2hhawnaqmdbxOyJnuQ8F23rO9Rcd59pY9vb3g8F1DJKSUk5xpn73MzBO2n6oA7lWdKt3+RBO+4xcwrS0VS0GyVKpfbIis3PfPp9VlvWKgYrjb92HAcAgK+gcsQwSrWjgoL/Ny5BHdh7UDB3R65C8d5CbZ/5KKgRtl8DvRZNCa+osiwFBdWiD+r4bqP7dv6g+v9Gis6/29JkObcfTYvGoMXJev9ZiIKCtAxEv9GyoLZi1JwhtRagoLbYBgDQbqCyPyJUUPAKZiuqixYUdGuK/1GroKCgoJvyP9+idj370sAUAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(-12 < x \\vee x < -38\\right) \\wedge - \\frac{2}{3} < x \\wedge x < 4$"
      ],
      "text/plain": [
       "(-12 < x ∨ x < -38) ∧ -2/3 < x ∧ x < 4"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.7.6 化简带有绝对值的不等式系统\n",
    "from sympy import Abs, Symbol\n",
    "from sympy.solvers.inequalities import reduce_abs_inequality\n",
    "x = Symbol('x', real=True)\n",
    "pprint([(Abs(3*x - 5) - 7, '<'), (Abs(x + 25) - 13, '>')])\n",
    "reduce_abs_inequalities([(Abs(3*x - 5) - 7, '<'), (Abs(x + 25) - 13, '>')], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d97becae-e1f3-41a8-b46e-446052e3aefd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(│x - 4│ + │3⋅x - 5│ - 7, <)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAUCAYAAACwN74uAAAEoklEQV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V8I3yAK3FQir5GiOvsOpyET0W0s28GeUaI3dmW926VmNtQsYhp+6lGllrp5Xc8VSKtSeqsSMr/mK5qSNMiHLa2It9aheO7Gufi+yrGyWG1uF30xvni541BIhi1VZC0FAZjkYhyDxNmYYYgwJwMMhSaJkIHrwvCDE3RR61kyaEavewQZC2WXk3qPJuUX8o1KnSERycJDkvyQWJXEIs/Vdjw0YJ9hc7fBHEN3Cl+w5pcRNgv8vrMip1YmqTczWWcOLKLYYBY1O3CcW9P3i/C+8KxPTORtTPsJ/yHbfaMY7SJqHezCGyWQq1kKYaseqkYhaQZIBY9H01JImz5VHEk9pZn5/LQJ8m7C5+mGN5ROWnysUPENRbaPUiWw7EiJtQhdvXGgu/ThJLvxRllxhoiot8L7BmcXCqc2JFiQxWLqNdSlnIop5eq0FDhXyPuEZNsUllcoI59GJX6NC0iqlknzP8QlQb3+tdUijr2KdT/EFVHZtRJU0dm/A2YYUlO0OIstwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} < x \\wedge x < 4$"
      ],
      "text/plain": [
       "1/2 < x ∧ x < 4"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pprint((Abs(x - 4) + Abs(3*x - 5) - 7, '<'))\n",
    "reduce_abs_inequalities([(Abs(x - 4) + Abs(3*x - 5) - 7, '<')], x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c8499f57-0c92-48f5-b0e6-61ffb5e14910",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
